package com.cheng.im.service.massage.controller;

import com.cheng.im.service.common.resp.CommonResult;
import com.cheng.im.service.message.model.req.GetMsgListReq;
import com.cheng.im.service.message.model.resp.MessageListResp;
import com.cheng.im.service.message.service.ImMessageHistoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * todo: 为了毕设演示搭建的临时链路
 */
@Slf4j
@RestController
@RequestMapping("v1/messageHistory")
public class MessageHistoryController {

    @Resource
    ImMessageHistoryService imMessageHistoryService;

    /**
     * 一整条调用链路都是临时的
     * @return
     */
    @PostMapping("/list")
    public CommonResult getList(@RequestBody GetMsgListReq getMsgListReq) {
        CommonResult<List<MessageListResp>> msgListByUserId = imMessageHistoryService
                .getMsgListByUserId(getMsgListReq.getOperator(),
                                    getMsgListReq.getOperator(),
                                    getMsgListReq.getToId(),
                                    getMsgListReq.getAppId());

        return msgListByUserId;
    }
}
